﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class UIYP : SDBASE
    {
        #region ==YPINFO===========
        public static readonly DependencyProperty YPINFOProperty = DependencyProperty.Register("YPINFO",
            typeof(string), typeof(UIYP),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnYPINFOChanged));
        public string YPINFO
        {
            get
            {
                return (string)GetValue(YPINFOProperty);
            }
            set
            {
                SetValue(YPINFOProperty, value);
            }
        }
        private static void OnYPINFOChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIYP;
            if (src != null)
            {
                src.YPINFO = (string)e.NewValue;
            }
        }
        #endregion 

       
        public UIYP()
        {
          
            
        }
        public override void LOADALL()
        {
            base.LOADALL();
            foreach (DataRow row in TBMain.Rows)
            {
                row["SDES"] = Helpers.Helper.Convert8859P1ToGB2312(row["SDES"].ToString().Trim());
                row["DES"] = Helpers.Helper.Convert8859P1ToGB2312(row["DES"].ToString().Trim());
            }
            if (SDSA.Length == 0) return;
            if (TBMain.Rows.Count > 0)
                return;
            if (DBSDDAT.ContainsKey(SDSA))
            {
                DBSDDAT.Remove(SDSA);
            }
            dwData = TBMain.NewRow();
            TMV.SetUpNewRow(ref dwData, SDSA);
            dwData["KEY"] = Helpers.Helper.ConvertGB2312To8859P1("1");
            dwData["DES"] = Helpers.Helper.ConvertGB2312To8859P1("船样");
            dwData["SDES"] = Helpers.Helper.ConvertGB2312To8859P1("船样");
            dwData["VALUE"] = Helpers.Helper.ConvertGB2312To8859P1("000000000");
            TMV.Save(dwData);
            dwData["KEY"] = Helpers.Helper.ConvertGB2312To8859P1("2");
            dwData["DES"] = Helpers.Helper.ConvertGB2312To8859P1("试样");
            dwData["SDES"] = Helpers.Helper.ConvertGB2312To8859P1("试样");
            dwData["VALUE"] = Helpers.Helper.ConvertGB2312To8859P1("000000000");
            TMV.Save(dwData);
            dwData["KEY"] = Helpers.Helper.ConvertGB2312To8859P1("11");
            dwData["DES"] = Helpers.Helper.ConvertGB2312To8859P1("左");
            dwData["SDES"] = Helpers.Helper.ConvertGB2312To8859P1("左");
            dwData["VALUE"] = Helpers.Helper.ConvertGB2312To8859P1("000000000");
            TMV.Save(dwData);
            dwData["KEY"] = Helpers.Helper.ConvertGB2312To8859P1("12");
            dwData["DES"] = Helpers.Helper.ConvertGB2312To8859P1("中");
            dwData["SDES"] = Helpers.Helper.ConvertGB2312To8859P1("中");
            dwData["VALUE"] = Helpers.Helper.ConvertGB2312To8859P1("000000000");
            TMV.Save(dwData);
            dwData["KEY"] = Helpers.Helper.ConvertGB2312To8859P1("13");
            dwData["DES"] = Helpers.Helper.ConvertGB2312To8859P1("右");
            dwData["SDES"] = Helpers.Helper.ConvertGB2312To8859P1("右");
            dwData["VALUE"] = Helpers.Helper.ConvertGB2312To8859P1("000000000");
            TMV.Save(dwData);
            LOADALL();
        }

    }
}
